package com.kevin.demo.controller.user;

import com.kevin.demo.annotation.AbleInsertLog;
import com.kevin.demo.entity.user.User;
import com.kevin.demo.framwork.Result;
import com.kevin.demo.service.user.UserService;
import com.kevin.demo.vo.input.user.UserFilters;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author: e20160504
 * @date: 2018/7/19
 * @desc
 */

@RestController
@Api(value = "UserController",description = "用户")
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "新增user")
    @PostMapping
    public Result insert(@RequestBody User user){
        return userService.insert(user);
    }

    @ApiOperation(value = "根据主键删除user")
    @DeleteMapping
    public Result delete(@RequestParam Integer id){
        return userService.delete(id);
    }

    @ApiOperation(value = "根据主键更新user")
    @PutMapping
    public Result update(User user){
        return userService.update(user);
    }

    @ApiOperation(value = "分页模糊查询user")
    @GetMapping
    public Result select(UserFilters filters) throws Exception{
        return userService.list(filters);
    }

}
